<template>
  <div>
    <el-form-item label="图片">
      <el-radio-group v-model="value.__config.mediaLocation">
        <el-radio
          v-for="item in imageLocationEnum"
          :key="item.code"
          :label="item.code"
          >{{ item.name }}</el-radio
        >
      </el-radio-group>

      <el-input
        size="small"
        v-show="value.__config.mediaLocation === 'remote'"
        type="textarea"
        rows="8"
        placeholder="请输入图片链接"
        v-model="value.__config.mediaSrc"
      ></el-input>

      <MediaUpload
        v-show="value.__config.mediaLocation === 'local'"
        accept="image/png, image/jpeg"
        :size="5"
        tip="只能上传png/jpg文件，且不超过5MB"
        :file.sync="value.__config.mediaSrc"
      />
    </el-form-item>
  </div>
</template>

<script>
import basicmixins from "../basicmixins";
import MediaUpload from "./MediaUpload";

export default {
  name: "ImageMediaBasicProps",
  components: {
    MediaUpload,
  },

  mixins: [basicmixins],

  data() {
    return {
      imageLocationEnum: [
        { code: "remote", name: "图片链接" },
        { code: "local", name: "图片上传" },
      ],
    };
  },

  watch: {
    "value.__config.mediaLocation"() {
      this.value.__config.mediaSrc = "";
    },
    
  },

  methods: {},
};
</script>

<style lang="scss"></style>
